<style>
    .layui-form-select{
        width: 187px;
    }
    .layui-form-label{
        width: 100px;
    }
</style>

<div class="layui-form" lay-filter="layui-company-edit-form-list" id="layui-company-edit-form-list"style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
        <label class="layui-form-label">公司名称</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="company_name" value="{{ d.params.company_name || '' }}" lay-verify="required" placeholder="请输入公司名称" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>

    <div class="layui-inline">
        <label class="layui-form-label" >所属国家</label>
    </div>
    <div class="layui-inline">
        <select name="base_country_name" class="selector" lay-verify="required" lay-search>
        </select>
    </div>

    <div class="layui-form-item" style="margin-top: 15px">
        <label class="layui-form-label">公司类型</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <select name="type" lay-verify="required">
                    <option value="">请选择</option>
                    <option value="1" {{ d.params.type == 1 ? 'selected' : '' }} >贸易公司</option>
                    <option value="2" {{ d.params.type == 2 ? 'selected' : '' }} >零售公司</option>
                    <option value="3" {{ d.params.type == 3 ? 'selected' : '' }} >贸易及零售公司</option>
                    <option value="4" {{ d.params.type == 4 ? 'selected' : '' }} >加盟及零售公司</option>
                    <option value="5" {{ d.params.type == 5 ? 'selected' : '' }} >供应商</option>
                </select>
            </script>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">销项加成比例</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="sale_proportion" onkeyup="clearNoNum(this)" value="{{ d.params.sale_proportion || '' }}" lay-verify="required" placeholder="请输入销项加成比例" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">公司地址</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="address" value="{{ d.params.address || '' }}" lay-verify="required" placeholder="请输入公司地址" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>

    <script type="text/html" template>
        <input type="hidden" name="id" value="{{ d.params.id || '' }}">
    </script>
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-inline">
            <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" value="确认" class="layui-btn">
        </div>
    </div>
</div>
<script type="text/javascript">
    layui.use(['laydate'], function () {
        var laydate = layui.laydate;
        laydate.render({
            elem: '#test-laydate-range-month'
            ,type: 'month'
            ,range: true
        });
    });

    /*销售项加成数据校验*/
    function clearNoNum(obj) {
        obj.value = obj.value.replace(/[^\d.]/g, "");  //清除“数字”和“.”以外的字符
        obj.value = obj.value.replace(/^\./g, "");  //验证第一个字符是数字而不是.
        obj.value = obj.value.replace(/^0*/g, "");  //验证第一个0清空.
        obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的.
        obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
    }
</script>
